import { defineComponent, PropType } from 'vue';
import { LdIcon } from '@/components/Icon';
// import Style1080 from '../../views/sqxzAddress/1080.module.scss';
// import Stylevedio from '../../views/sqxzAddress/vediotop.module.scss';
import { KEEP_VIDEO_TOP } from '@/config';
import router from "@/router";
import {useBreadcrumbStore} from "@/store/modules/breadcrumb";
import {dzInfo, ItemInfo} from "@/api/typing";
import Style1080 from './1080.module.scss';
import Stylevedio from './vediotop.module.scss';



export default defineComponent({
    props: {
        /** 路由跳转路径 */
        to: {
            type: String,
            default: ''
        },
        /** Item的完整信息 */
        itemInfo: {
            type: Object as PropType<dzInfo>,
            required: true
        }
    },
    setup(props, { slots, attrs }) {
        const Style = KEEP_VIDEO_TOP ? Stylevedio : Style1080;

        // 处理点击事件，携带信息跳转
        const handleClick = () => {
            const breadcrumbStore = useBreadcrumbStore(); // 实例化Pinia存储
            breadcrumbStore.addTitle(props.itemInfo.name);
            if (props.to) {
                router.push({
                    path: props.to,
                    query: {
                        // 将item信息转换为JSON字符串传递
                        itemInfo: JSON.stringify(props.itemInfo)
                    }
                });
            }
        };

        return () => (<>
            <div
                onClick={handleClick}
                {...attrs}
                class={Style.item}
                // 添加鼠标指针样式，提示可点击
                style={{ cursor: 'pointer' }}
            >
                {slots.default?.()}
            </div>
        </>);
    }
})
